package io.aicn.lowcode.entity.dbmanager;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * 数据域实体类
 * 
 * @author lowcode-generator
 * @since 2025-01-25
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("dbm_data_domain")
public class DataDomain {

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 域名称
     */
    @TableField("domain_name")
    private String domainName;

    /**
     * 域编码
     */
    @TableField("domain_code")
    private String domainCode;

    /**
     * 数据类型
     */
    @TableField("data_type")
    private String dataType;

    /**
     * 数据长度
     */
    @TableField("data_length")
    private Integer dataLength;

    /**
     * 小数位数
     */
    @TableField("decimal_places")
    private Integer decimalPlaces;

    /**
     * 默认值
     */
    @TableField("default_value")
    private String defaultValue;

    /**
     * 是否允许为空
     */
    @TableField("is_nullable")
    private Boolean isNullable;

    /**
     * 验证规则
     */
    @TableField("validation_rule")
    private String validationRule;

    /**
     * 域描述
     */
    @TableField("description")
    private String description;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /**
     * 创建人
     */
    @TableField(value = "create_by", fill = FieldFill.INSERT)
    private String createBy;

    /**
     * 更新人
     */
    @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
    private String updateBy;

    /**
     * 域类型枚举
     */
    public enum DomainType {
        BASIC("basic", "基础域"),
        BUSINESS("business", "业务域"),
        SYSTEM("system", "系统域");

        private final String code;
        private final String description;

        DomainType(String code, String description) {
            this.code = code;
            this.description = description;
        }

        public String getCode() {
            return code;
        }

        public String getDescription() {
            return description;
        }
    }
}